<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class News_model extends MY_Model {
	public function __construct() {
		parent::__construct ( 'news' );
	}
	/**
	 * 创建数据表
	 */
	public function create() {
		$this->drop ();
		$sql = "CREATE TABLE `news` (
					  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '新闻ID',
					  `title` varchar(40) NOT NULL COMMENT '标题',
					  `content` text COMMENT '新闻内容',
					  `category` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '类别',
					  `author` varchar(10) NOT NULL COMMENT '作者',
					  `updatetime` int(10) unsigned NOT NULL COMMENT '修改时间',
					  `tags` varchar(100) DEFAULT NULL COMMENT '标签',
					  PRIMARY KEY (`id`)
					) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='新闻管理表';";
		$re = $this->db->simple_query ( $sql );
	}
	/**
	 * 删除数据表
	 */
	public function drop() {
		$sql = 'DROP TABLE IF EXISTS `news`;';
		$re = $this->db->simple_query ( $sql );
		return $re;
	}
}